<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>预算定制</title>
<%@include file="/common/meta.jsp"%>
<%@include file="/common/validator.jsp"%>
<style type="text/css">
.budgetItem {
	width: 90px;
	height: 20px;
	border: 0px;
	color: green;
	font-weight: bold;
	text-align: right;
	margin: 0px;
	padding: 2px;
}

.showBorder {
	width: 90px;
	height: 20px;
	border: 0px; border-bottom : 1px solid red;
	color: green;
	text-align: right;
	font-weight: bold;
	margin: 0px;
	padding: 2px;
	border-bottom: 1px solid red;
}

.budgetTable {
	margin: auto;
	border-top: 1px solid #000000;
	border-left: 1px solid #000000;
}

.budgetTable tr td {
	height: 30px;
	padding: 2px;
	border-bottom: 1px solid #000000;
	border-right: 1px solid #000000;
	border-bottom: 1px solid #000000;
}

.budgetTable tr th {
	background-color: #ECECEC;
	height:30px;
 	font-weight: bold;
 	font-size:13px;
 	text-align: center;
	border-bottom: 1px solid #000000;
	border-right: 1px solid #000000;
	font-family: sans-serif;
}

#noBorder {
	border: 0px;
}

.errorMsg {
	width: 500px;
	height: 100px;
	color: red;
	text-align: left;
	padding: 20px 5px;
	border: 1px solid #CCC;
}
</style>
</head>
<body>
<div class="x-panel">
<div style="margin: 5px;">
  <%@ include file="/common/messages.jsp"%>
  <s:if test="model.project == null || model.project.projectType.items.size == 0">
    <input type="button" value="选择项目" class="button" onclick="openSelect()" style="margin: 5px auto;">
  </s:if>
<s:form action="save.do" method="post" cssStyle="margin:auto;">
  <s:hidden name="model.id" />
  <table class="budgetTable" cellpadding="0" cellspacing="0" style="border-top: 2px solid; margin-top: 5px;">
    <tr>
      <th width="352">项目名称 </th>
      <th width="200">项目周期 </th>
      <th width="100">预算定制日期</th>
      <th width="100">预算定制人</th>
      <th width="100">预算额</th>
    </tr>
    <s:if test="model.project != null">
    <tr>
      <td style="color: navy;">&nbsp;
        <b>${model.project.name}</b>&nbsp;/&nbsp;
        ${model.project.projectType.name}
      </td>
      <td style="color: navy;"><s:date name="model.project.startTime" format="yyyy年MM月dd日"/>&nbsp;-&nbsp;<s:date name="model.project.endTime" format="yyyy年MM月dd日"/>&nbsp;</td>
      <td style="color: navy; ">&nbsp;
        <s:date name="model.createTime" format="yyyy年MM月dd日"/>
      </td>
      <td style="color: navy; ">&nbsp;${model.creater.name}</td>
      <td style="color: red; font-family: sans-serif; font-size: 14px;" align="right">
        ${model.amount}&nbsp;&yen;&nbsp;
      </td>
    </tr>
    </s:if>
  </table>
  <table class="budgetTable" cellpadding="0" cellspacing="0">
    <s:if test="model.proItemBudgets.size != 0">
      <tr>
        <th width="70">科目编号</th>
        <th width="180">科目名称</th>
        <th width="100">预算金额</th>
        <th width="99">第1次追加</th>
        <th width="100">第2次追加</th>
        <th width="100">第3次追加</th>
        <th width="100">第4次追加</th>
        <th width="100">最终金额</th>
      </tr>
      <s:iterator value="model.proItemBudgets" var="pib">
        <tr>
          <td>
            ${pib.item.code}
            <input type="hidden" name="pibIds" value="${pib.id}">
          </td>
          <td>${pib.item.name}</td>
          <td align="center">
            <input type="text" id="pibAmount_${pib.id}" name="pibAmount_${pib.id}" class="budgetItem" value="${pib.amount}" maxlength="12" onfocus="showBorder(this)" onblur="hiddenBorder(this)"/></td>
          <td align="center">
            <input type="text" id="pibAdd1th_${pib.id}" name="pibAdd1th_${pib.id}" class="budgetItem" value="${pib.add1th}" maxlength="12" onfocus="showBorder(this)" onblur="hiddenBorder(this)"/></td>
	      <td align="center">
	        <input type="text" id="pibAdd2th_${pib.id}" name="pibAdd2th_${pib.id}" class="budgetItem" value="${pib.add2th }" maxlength="12" onfocus="showBorder(this)" onblur="hiddenBorder(this)"/></td>
	      <td align="center">
	        <input type="text" id="pibAdd3th_${pib.id}" name="pibAdd3th_${pib.id}" class="budgetItem" value="${pib.add3th }" maxlength="12" onfocus="showBorder(this)" onblur="hiddenBorder(this)"/></td>
	      <td align="center">
	        <input type="text" id="pibAdd4th_${pib.id}" name="pibAdd4th_${pib.id}" class="budgetItem" value="${pib.add4th }" maxlength="12" onfocus="showBorder(this)" onblur="hiddenBorder(this)"/></td>
	      <td align="right" style="color: red; font-size: 14px; font-family: sans-serif;">
	        ${pib.finalAmount}&nbsp;&yen;&nbsp;</td>
        </tr>
      </s:iterator>
    </s:if>
    <s:else>
      <tr>
        <td colspan="8">
	      &nbsp;该项目所属类别未配置预算科目
        </td>
      </tr>
    </s:else>
  </table>
  <table width="850">
    <tr>
      <td align="center">
		  <input type="submit" value="保存" class="button" style="margin: 5px auto;"/> &nbsp;&nbsp;
		  <input type="button" value="返回" class="button" onclick="openIndex()" style="margin: 5px auto;">
      </td>
    </tr>
  </table>
</s:form>
</div>
</div>
<script type="text/javascript">
	function openSelect() {
		var url = '${ctx}/base/project/selectProject.do';
		var styles = "dialogWidth:552px; dialogHeight:365px; status:no; scroll:no; help:no";
		var project = window.showModalDialog(url, null, styles);
		if (project != null) {
			window.location.href = "editNew.do?model.project.id="
					+ project.id;
		}
	}
	function showBorder(obj) {
		obj.className = 'showBorder';
	}

	function hiddenBorder(obj) {
		obj.className = 'budgetItem';
	}
	
	function openIndex(){
		window.location.href = "index.do";
	}
</script>
</body>
</html>